package com.hengxinguotong.baselibrary.dialog;

import android.content.Context;

import com.hengxinguotong.baselibrary.wheel.AbstractWheelTextAdapter;

import java.util.List;

/**
 * Created by hjz on 2018/4/10.
 */

public class ITextAdapter<T> extends AbstractWheelTextAdapter
{
    private List<T> iTextList;

    public ITextAdapter(Context context, List<T> iTextList)
    {
        super(context);
        this.iTextList = iTextList;
    }

    @Override
    public int getItemsCount()
    {
        if (iTextList != null)
        {
            return iTextList.size();
        }
        return 0;
    }

    @Override
    protected CharSequence getItemText(int index)
    {
        if (iTextList != null)
        {
            T item = iTextList.get(index);
            if (item instanceof IText)
            {
                return ((IText) item).getText();
            }
        }
        return null;
    }
}
